﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Web.Utils;

namespace Web.usercontrols
{
    public partial class AdminLeftNavigation : System.Web.UI.UserControl
    {
        

        bool hasSelected = false;
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        public string GetSelected(string rootMenu)
        {
            var selectorString = "";
            if (!hasSelected)
            {
                var currentUrl = this.Request.Url.ToString().ToLower();
                switch (rootMenu)
                {
                    case "FileMenu":
                        if (MenuHelper.FileMenus.Any(s => currentUrl.Contains(s)))
                            selectorString = "id='submenu-active'";
                        break;
                    case "UtilitiesMenu":
                        if (MenuHelper.UtilitesMenus.Any(s=>currentUrl.Contains(s)))
                            selectorString = "id='submenu-active'";
                        break;
                }

                hasSelected = !string.IsNullOrEmpty(selectorString);
            }

            return selectorString;
        }
    }
}